/**
 * 项目名：	Rumba Plan
 * 
 * 版权所有(C)，上海海鼎信息工程股份有限公司，2006，所有权利保留。
 * 
 * 文件名：	BResultPage.java
 * 模块说明：	
 * 修改历史：
 * 2006-7-11 - lxm - 创建。
 */
package com.hd123.rumba.sql.biz;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import net.sf.hibernate.HibernateException;

import com.hd123.rumba.exception.BusinessException;
import com.hd123.rumba.sql.ResultPage;

/**
 * @author lxm
 * 
 */
public class BResultPage implements Serializable {

  private static final long serialVersionUID = 300100L;
  private int page;
  private int pageSize;
  private int elementCount;
  private int pageCount;
  private List values = new ArrayList();

  public void assignFrom(ResultPage rp) throws BusinessException, HibernateException {
    this.page = rp.getPage();
    this.pageSize = rp.getPageSize();
    this.elementCount = rp.getElementCount();
    this.pageCount = rp.getPageCount();

    List list = rp.getContentList();
    for (int i = 0; i < list.size(); i++) {
      Object[] record = null;
      if (list.get(i) instanceof Object[])
        record = (Object[]) list.get(i);
      else {
        record = new Object[1];
        record[0] = list.get(i);
      }
      List lsRecord = new ArrayList();
      for (int j = 0; j < record.length; j++)
        lsRecord.add(record[j]);
      values.add(lsRecord);
    }
  }

  public int getElementCount() {
    return elementCount;
  }

  public void setElementCount(int elementCount) {
    this.elementCount = elementCount;
  }

  public int getPage() {
    return page;
  }

  public void setPage(int page) {
    this.page = page;
  }

  public int getPageCount() {
    return pageCount;
  }

  public void setPageCount(int pageCount) {
    this.pageCount = pageCount;
  }

  public int getPageSize() {
    return pageSize;
  }

  public void setPageSize(int pageSize) {
    this.pageSize = pageSize;
  }

  public List getValues() {
    return values;
  }

  public void setValues(List values) {
    this.values = values;
  }

  public void assignFrom2(ResultPage rp) throws BusinessException, HibernateException {
    this.page = rp.getPage();
    this.pageSize = rp.getPageSize();
    this.elementCount = rp.getElementCount();
    this.pageCount = rp.getPageCount();

    List list = rp.getContentList();
    for (int i = 0; i < list.size(); i++) {
      Object[] record = null;
      if (list.get(i) instanceof Object[])
        record = (Object[]) list.get(i);
      else {
        record = new Object[1];
        record[0] = list.get(i);
      }
      values.add(record);
    }
  }

}
